package com.parktech.sun.web.controller;

import com.parktech.sun.domain.service.specialtopic.SpecialTopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * User: Think
 * Date: 11-1-19
 * Time: 上午1:27
 */
@Controller
@RequestMapping("/specialtopic")
public class SpecialTopicViewController extends BaseViewController {

    private SpecialTopicService specialTopicService;

    @Autowired
    public SpecialTopicViewController(SpecialTopicService specialTopicService) {
        this.specialTopicService = specialTopicService;
    }

    @RequestMapping("/{categoryId}")
    public String view(@PathVariable("categoryId") Long specialTopicCategoryId, Model model) {
        model.addAttribute(specialTopicService.getByCategoryId(specialTopicCategoryId));
        return "specialtopic";
    }

    @RequestMapping("/contents/{specialTopicId}")
    public String viewDetail(@PathVariable("specialTopicId") Long specialTopicId, Model model) {
        model.addAttribute(specialTopicService.getById(specialTopicId));
        return "specialtopicDetail";
    }
}
